package at.tasat.solver;

import at.tasat.util.IntStack;

public final class SolverException extends Exception {

	private static final long serialVersionUID = 4055882417017949359L;

	private final int state;
	private final IntStack states;

	public SolverException(Throwable inner, int state, IntStack states) {
		super("An unexpected error has occured!", inner);
		this.state = state;
		this.states = states;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(super.toString());
		builder.append('\n');
		builder.append(state);
		builder.append('(');
		boolean first = true;
		for (Integer s : states) {
			if (first) {
				first = false;
			} else {
				builder.append(',');
			}
			builder.append(s);
		}
		builder.append(')');
		return builder.toString();
	}

}
